//
//  BYConfirmOrderGoodsCell.m
//  OCDemo
//
//  Created by zhumuzhi on 2022/2/16.
//

#import "BYConfirmOrderGoodsCell.h"

@interface BYConfirmOrderGoodsCell ()

// 商品图片
@property (nonatomic, strong) UIImageView       *goodImage;
// 商品标题
@property (nonatomic, strong) UILabel           *goodTitle;
// 商品价格
@property (nonatomic, strong) UILabel           *goodPrice;
// 商品价格
@property (nonatomic, strong) UILabel           *goodCount;

@end

@implementation BYConfirmOrderGoodsCell

#pragma mark - SetData

#pragma mark - CellHeight
+(CGFloat)cellHeight {
    return kAutoWithSize(100);
}

#pragma mark - init

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self.contentView addSubview:self.goodImage];
        [self.contentView addSubview:self.goodTitle];
        [self.contentView addSubview:self.goodPrice];
        [self.contentView addSubview:self.goodCount];
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    [self.goodImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(kAutoWithSize(10));
        make.left.equalTo(self.contentView).offset(kAutoWithSize(10));
        make.width.height.mas_equalTo(kAutoWithSize(72));
    }];
    
    [self.goodTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(kAutoWithSize(10));
        make.left.equalTo(self.goodImage.mas_right).offset(kAutoWithSize(10));
        make.right.equalTo(self.contentView.mas_right).offset(-kAutoWithSize(10));
    }];
    
    [self.goodPrice mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.goodImage);
        make.left.equalTo(self.goodTitle);
    }];
    
    [self.goodCount mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.goodPrice.mas_right);
        make.bottom.equalTo(self.goodPrice);
    }];
    
}


#pragma mark - LazyGet
- (UIImageView *)goodImage{
    if (!_goodImage) {
        _goodImage = [[UIImageView alloc] init];
        _goodImage.image = [UIImage imageNamed:@"p01"];
    }
    return _goodImage;
}

- (UILabel *)goodTitle{
    if (!_goodTitle) {
        _goodTitle = [[UILabel alloc]init];
        _goodTitle.font = MZBoldFont(14);
        _goodTitle.textColor = [UIColor blackColor];
        _goodTitle.text = @"商品标题";
    }
    return _goodTitle;
}

- (UILabel *)goodPrice{
    if (!_goodPrice) {
        _goodPrice = [[UILabel alloc]init];
        _goodPrice.font = MZFont(13);
        _goodPrice.textColor = [UIColor redColor];
        _goodPrice.text = @"¥2881";
    }
    return _goodPrice;
}

- (UILabel *)goodCount{
    if (!_goodCount) {
        _goodCount = [[UILabel alloc]init];
        _goodCount.font = MZFont(13);
        _goodCount.textColor = [UIColor redColor];
        _goodCount.text = @" x 1";
    }
    return _goodCount;
}

@end
